package com.qf.flash.ui.login;

import android.content.Intent;
import android.os.Handler;

import com.hyphenate.chat.EMClient;
import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.R;
import com.qf.flashlib.base.BaseActivity;

/**
 * 描述:
 * 2020/3/18 18:17
 */
public class SplashActivity extends BaseActivity {
    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initViewAndData() {
       new Thread(new Runnable() {
           @Override
           public void run() {
               if(EMClient.getInstance().isLoggedInBefore()){
                   EMClient.getInstance().chatManager().loadAllConversations();
                   EMClient.getInstance().groupManager().loadAllGroups();
               }
           }
       }).start();

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (UserMgr.getInstance().getLoginUser()!= null) {
                    HomeActivity.start(SplashActivity.this, 0);
                } else {
                    startActivity(new Intent(SplashActivity.this, MainActivity.class));
                }
                finish();
            }
        }, 1200);

    }
}
